package com.vzaar.transport.httpclient4;

import oauth.signpost.AbstractOAuthConsumer;
import oauth.signpost.http.HttpRequest;
import oauth.signpost.signature.SignatureMethod;

/**
 * Support for OAuth and commons HTTP 4 client using the signpost 1.1
 * open source library.
 * 
 * @author Marc G. Smith
 */
@SuppressWarnings("serial")
class CommonsHttpOAuthConsumer extends AbstractOAuthConsumer 
{
	///////////////////////////////////////////////////////////////////////////
	// Public Methods /////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////
	
    /**
     * Create the OAuth consumer.
     * 
     * @param consumerKey the OAuth consumer key
     * @param consumerSecret the OAuth consumer secret
     * @param signatureMethod the signature method
     */
	public CommonsHttpOAuthConsumer(
    	String consumerKey, String consumerSecret,     
    	SignatureMethod signatureMethod) 
    {
        super(consumerKey, consumerSecret, signatureMethod);
    }

	///////////////////////////////////////////////////////////////////////////
	// Protected Methods //////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////


	/**
	 * Wrap the request method object.
	 */
	@Override
    protected HttpRequest wrap(Object request) {
        if (!(request instanceof org.apache.http.HttpRequest)) {
            throw new IllegalArgumentException(
            	"This consumer expects requests of type " +
                org.apache.http.HttpRequest.class.getCanonicalName());
        }

        return new HttpRequestAdapter((org.apache.http.HttpRequest) request);
    }

	///////////////////////////////////////////////////////////////////////////
}
